<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" href="../../assets/layui/css/layui.css" media="all" />
		<link rel="stylesheet" href="../../assets/css/admin.css" />			
	</head>

	<body>
		<div style="margin: 30px;">
			<form class="layui-form" action="" method="post" onsubmit="return false;">
				<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
					<legend>策略基本信息</legend>
				</fieldset>
				<div class="layui-form-item">
					<div class="layui-inline">
					<label class="layui-form-label"><span style="color: red">*</span>策略名称</label>
						<div class="layui-input-inline">
							<input type="text" name="prodName" id="prodName" 
								   autocomplete="off" placeholder="请输入策略名称" class="layui-input" required>
						</div>
					</div>
					<input type="hidden" name="prodId" id="prodId">
					<input type="hidden" name="type" id="type">
					<div class="layui-inline">
						<label class="layui-form-label"><span style="color: red">*</span>交易平台</label>
						<div class="layui-input-inline">
							<select name="coinId" id="coinId" lay-filter="coinIdF" required>
							<option value="">请选择</option>
							</select>
						</div>
					</div>
					
				</div>
				
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label"><span style="color: red">*</span>交易币种</label>
						<div class="layui-input-inline">
							<select name="coinId" id="coinId" lay-filter="coinIdF" required>
							<option value="">请选择</option>
							</select>
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label"><span style="color: red">*</span>开仓档位</label>
						<div class="layui-input-inline">
							<select name="purLevel" id="purLevel" required>
							<option value="">请选择</option>
							</select>
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label"><span style="color: red">*</span>基础价格（$）</label>
					<div class="layui-input-inline">
						<input type="text" name="basePrice" id="basePrice" required
							 autocomplete="off" placeholder="请输入基础价格$" class="layui-input" onchange="allchange()" >
					</div>
				</div>
				
				<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
					<legend>看多策略</legend>
				</fieldset>
				
				<div id="morestrategy"  >
				<div class="layui-form-item">
					<label class="layui-form-label"><span style="color: red">*</span>是否开启</label>
					<div class="layui-input-block">
						<input type="checkbox" checked="checked" value="true" name="isMoreStrategy" id="isMoreStrategy" lay-skin="switch" lay-filter="switch1">
						<input id="isMoreStrategynew" value="1" style="display:none;"/>
						<label style="display:inline;vertical-align:middle;"><span style="color: red">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;说明：所有比例计算，均以开仓价格进行比例计算</span></label>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label"><span style="color: red">*</span>开仓比例（%）</label>
						<div class="layui-input-inline">
							<input type="number" name="riseOpenPrice" id="riseOpenPrice" 
								autocomplete="off" placeholder="请输入开仓比例%" class="layui-input" onchange="sum(this,'more')">
						</div>
						<div class="layui-form-mid layui-word-aux" style="color: red;margin-left: -20px;font-weight:bold;"></div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label"><span style="color: red">*</span>止损比例（%）</label>
						<div class="layui-input-inline">
							<input type="number" name="riseStoplossPrice" id ="riseStoplossPrice" 
								autocomplete="off" placeholder="请输入止损比例%" class="layui-input" onchange="sum0(this)">
						</div>
						<div class="layui-form-mid layui-word-aux" style="color: red;margin-left: -20px;font-weight:bold;"></div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label"><span style="color: red">*</span>放弃开仓比例（%）</label>
						<div class="layui-input-inline">
							<input type="number" name="riseAbandonPrice" id="riseAbandonPrice" 
								autocomplete="off" placeholder="请输入放弃开仓比例%"  class="layui-input" onchange="sum0(this)">
						</div>
						<div class="layui-form-mid layui-word-aux" style="color: red;margin-left: -20px;font-weight:bold;"></div>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">策略阶段</label>
					<div class="layui-input-block">
						<a href="javascript:;" class="layui-btn layui-btn-warm" id="more-add">
							<i class="layui-icon">&#xe608;</i> 添加阶段
						</a>
					</div>
				</div>
				<div class="layui-form-item" id="more1">
					<label class="layui-form-label"><span style="color: red">*</span>阶段1（%）</label>
					<div class="layui-input-inline">
						<input type="number" name="moreTradeStrategys[1].triggerPrice" id="more-remedyPrice1" 
							   autocomplete="off" placeholder="请输入触发%" class="layui-input more-sum" onchange="sum0(this)">
					</div>
					<div class="layui-form-mid layui-word-aux" style="color: red;margin-left: -20px;font-weight:bold;"></div>
					<div class="layui-form-mid" style="width: 100px;">————</div>
					<div class="layui-input-inline">
						<input type="number" name="moreTradeStrategys[1].sellPrice" id="more-sellPrice1" 
							   autocomplete="off" placeholder="请输入回调%" class="layui-input more-sum" onchange="sum0(this)">
					</div>
					<div class="layui-form-mid layui-word-aux" style="color: red;margin-left: -20px;font-weight:bold;"></div>
					<input type="hidden" name="moreTradeStrategys[1].tradeStrategyTrendType" value="1">
				</div>
				<div class="layui-form-item" id="more-loop">
					<label class="layui-form-label"><span style="color: red">*</span>循环执行价格（$）</label>
					<div class="layui-input-inline">
						<input type="number" name="moreTradeStrategys[0].triggerPrice" id="more-remedyPrice0" 
							   autocomplete="off" placeholder="请输入触发梯度金额$" class="layui-input" >
					</div>
					<div class="layui-form-mid" style="width: 100px;">————</div>
					<div class="layui-input-inline">
						<input type="number" name="moreTradeStrategys[0].sellPrice" id="more-sellPrice0" 
							   autocomplete="off" placeholder="请输入回调平仓梯度金额$" class="layui-input" >
					</div>
					<input type="hidden" name="moreTradeStrategys[0].tradeStrategyTrendType" value="2">
				</div>
				</div>
				
				<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
					<legend>看空策略</legend>
				</fieldset>
				<div id="nullstrategy" >
				<div class="layui-form-item">
					<label class="layui-form-label"><span style="color: red">*</span>是否开启</label>
					
					<div class="layui-input-block">
						<input type="checkbox" checked="checked" value="true" name="isNullStrategy" id="isNullStrategy" lay-skin="switch" lay-filter="switch2">
						<input id="isNullStrategynew" value="1" style="display:none;"/>
						<label style="display:inline;vertical-align:middle;"><span style="color: red">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;说明：所有比例计算，均以开仓价格进行比例计算</span></label>
					</div>
				</div>
				
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label"><span style="color: red">*</span>开仓比例（%）</label>
						<div class="layui-input-inline">
							<input type="number" name="fallOpenPrice" id="fallOpenPrice"  
								autocomplete="off" placeholder="请输入开仓比例%" class="layui-input" onchange="sum(this,'fall')">
						</div>
						<div class="layui-form-mid layui-word-aux" style="color: red;margin-left: -20px;font-weight:bold;"></div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label"><span style="color: red">*</span>止损比例（%）</label>
						<div class="layui-input-inline">
							<input type="number" name="fallStoplossPrice" id="fallStoplossPrice" 
								autocomplete="off" placeholder="请输入止损比例%" class="layui-input" onchange="sum1(this)">
						</div>
						<div class="layui-form-mid layui-word-aux" style="color: red;margin-left: -20px;font-weight:bold;"></div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label"><span style="color: red">*</span>放弃开仓比例（%）</label>
						<div class="layui-input-inline">
							<input type="number" name="fallAbandonPrice" id="fallAbandonPrice" 
								autocomplete="off" placeholder="请输入放弃开仓比例%"  class="layui-input" onchange="sum1(this)">
						</div>
						<div class="layui-form-mid layui-word-aux" style="color: red;margin-left: -20px;font-weight:bold;"></div>
					</div>
				</div>
				<div class="layui-form-item" >
					<label class="layui-form-label">策略阶段</label>
					<div class="layui-input-block">
						<a href="javascript:;" class="layui-btn layui-btn-warm" id="null-add">
							<i class="layui-icon">&#xe608;</i> 添加阶段
						</a>
					</div>
				</div>
				<div class="layui-form-item" id="null1">
					<label class="layui-form-label"><span style="color: red">*</span>阶段1（%）</label>
					<div class="layui-input-inline">
						<input type="number" name="nullTradeStrategys[1].triggerPrice" id="null-remedyPrice1" 
							   autocomplete="off" placeholder="请输入触%" class="layui-input null-sum" onchange="sum1(this)">
					</div>
					<div class="layui-form-mid layui-word-aux" style="color: red;margin-left: -20px;font-weight:bold;"></div>
					<div class="layui-form-mid" style="width: 100px;">————</div>
					<div class="layui-input-inline">
						<input type="number" name="nullTradeStrategys[1].sellPrice" id="null-sellPrice1" 
							   autocomplete="off" placeholder="请输入回调%" class="layui-input null-sum" onchange="sum1(this)">
					</div>
					<div class="layui-form-mid layui-word-aux" style="color: red;margin-left: -20px;font-weight:bold;"></div>
					<input type="hidden" name="nullTradeStrategys[1].tradeStrategyTrendType" value="1">
				</div>
				<div class="layui-form-item" id="null-loop">
					<label class="layui-form-label"><span style="color: red">*</span>循环执行价格（$）</label>
					<div class="layui-input-inline">
						<input type="number" name="nullTradeStrategys[0].triggerPrice" id="null-remedyPrice0" 
							   autocomplete="off" placeholder="请输入触发梯度金额$" class="layui-input" >
					</div>
					<div class="layui-form-mid" style="width: 100px;">————</div>
					<div class="layui-input-inline">
						<input type="number" name="nullTradeStrategys[0].sellPrice" id="null-sellPrice0" 
							   autocomplete="off" placeholder="请输入回调平仓梯度金额$" class="layui-input" >
					</div>
					<input type="hidden" name="nullTradeStrategys[0].tradeStrategyTrendType" value="2">
				</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn" lay-submit="" lay-filter="demo1">提交</button>
						<button type="reset" class="layui-btn layui-btn-primary">重置</button>
					</div>
				</div>
			</form>
		</div>
		<script type="text/javascript" src="../../js/common/jquery-1.10.2.min.js"></script>
		<script type="text/javascript" src="../../assets/layui/layui.js"></script>
		<script type="text/javascript" src="../../assets/plugins/jquery-validation-1.14.0/dist/jquery.validate.min.js"></script>
		<script type="text/javascript" src="../../assets/plugins/jquery-validation-1.14.0/lib/jquery.form.js"></script>
		<script type="text/javascript" src="../../assets/plugins/jquery-validation-1.14.0/dist/localization/messages_zh.min.js"></script>
		<script type="text/javascript" src="../../js/common/formUtil.js"></script>
		<script type="text/javascript" src="../../js/common/commonUtil.js"></script>
		<script type="text/javascript">
		function sum(obj,flag){
			$(obj).parent().next().html(accMul(accAdd(1.0,accMul($(obj).val(),0.01)),$("#basePrice").val()));
			console.log(flag);
			if(flag == "more"){
				morechange();
			}
			else if(flag == "fall"){
				nullchange();
			}
					
		}
		function sum0(obj){
			$(obj).parent().next().html(accMul(accAdd(1.0,accMul($(obj).val(),0.01)),accMul(accAdd(1.0,accMul($("#riseOpenPrice").val(),0.01)),$("#basePrice").val())));
		}
		function sum1(obj){
			$(obj).parent().next().html(accMul(accAdd(1.0,accMul($(obj).val(),0.01)),accMul(accAdd(1.0,accMul($("#fallOpenPrice").val(),0.01)),$("#basePrice").val())));
		}
		function allchange(){
			sum($("#riseOpenPrice"),'');
			sum($("#fallOpenPrice"),'');
			sum0($("#riseStoplossPrice"));
			sum1($("#fallStoplossPrice"));
			sum0($("#riseAbandonPrice"));
			sum1($("#fallAbandonPrice"));
			$(".layui-input.more-sum").each(function(i, btn) {  
				sum0(btn); 
			});  
			$(".layui-input.null-sum").each(function(i, btn) {  
				sum1(btn); 
			}); 
		}
		function morechange(){
			sum0($("#riseStoplossPrice"));
			sum0($("#riseAbandonPrice"));
			$(".layui-input.more-sum").each(function(i, btn) {  
				sum0(btn); 
			});  
		}
		function nullchange(){
			sum1($("#fallStoplossPrice"));
			sum1($("#fallAbandonPrice"));
			$(".layui-input.null-sum").each(function(i, btn) {  
				sum1(btn); 
			});  
		}
		var more_index = 1;
		var null_index = 1;
		 var path = "../..";
			layui.config({
				base: '../../assets/' //静态资源所在路径
			}).extend({
				index: 'lib/index' //主入口模块
			}).use(['index','layer','form'], function() {
				var $ = layui.jquery,
					layer = layui.layer,
				    form = layui.form;
				form.on('switch(switch1)', function (data) {
	                if(data.elem.checked){
	                	for (var i = 0; i <= more_index; i++) {
	                		$("#more-remedyPrice"+i).rules("add", {required:true});
							$("#more-sellPrice"+i).rules("add", {required:true});
	                	}
						$("#riseOpenPrice").rules("add", {required:true});
						$("#riseStoplossPrice").rules("add", {required:true});
						$("#riseAbandonPrice").rules("add", {required:true});
						$("#morestrategy").removeClass("strategyclass");
						$("#morestrategy").val(true);
						$("#isMoreStrategynew").val(2);
					}else{
						for (var i = 0; i <= more_index; i++) {
	                		$("#more-remedyPrice"+i).rules("remove");
							$("#more-sellPrice"+i).rules("remove");
	                	}
						$("#riseOpenPrice").rules("remove");
						$("#riseStoplossPrice").rules("remove");
						$("#riseAbandonPrice").rules("remove");
						$("#morestrategy").addClass("strategyclass");
						$("#morestrategy").val(false);
						$("#isMoreStrategynew").val(3);
					}
	            });
				form.on('switch(switch2)', function (data) {
	                if(data.elem.checked){
	                	for (var i = 0; i <= null_index; i++) {
	                		$("#null-remedyPrice"+i).rules("add", {required:true});
							$("#null-sellPrice"+i).rules("add", {required:true});
	                	}
						$("#fallOpenPrice").rules("add", {required:true});
						$("#fallStoplossPrice").rules("add", {required:true});
						$("#fallAbandonPrice").rules("add", {required:true});
						$("#nullstrategy").removeClass("strategyclass");
						$("#nullstrategy").val(true);
						$("#isNullStrategynew").val(2);
						
					}else{
						for (var i = 0; i <= null_index; i++) {
	                		$("#null-remedyPrice"+i).rules("remove");
							$("#null-sellPrice"+i).rules("remove");
	                	}
						$("#fallOpenPrice").rules("remove");
						$("#fallStoplossPrice").rules("remove");
						$("#fallAbandonPrice").rules("remove");
						$("#nullstrategy").addClass("strategyclass");
						$("#nullstrategy").val(false);
						$("#isNullStrategynew").val(3);
					}
	            });
				
				$("#prodId").val("<%=prodId%>");
				var coinId = ""
				var purLevel = ""
				if (!ComUtil.isEmpty($("#prodId").val())) {
					ComUtil.AjaxData(".layui-form", "/a/setting/StrategyAction/queryProductStrategyByKey.do", 
					function(obj, data) {
						if(data.data){
							var val = data.data;
							coinId = val.coinId;
							purLevel = val.purLevel;
							$("#prodName").val(val.prodName);
							$("input[type=radio][name=level][value="+val.level+"]").attr("checked",'checked')
							$("#riseOpenPrice").val(val.riseOpenPrice);
							$("#riseStoplossPrice").val(val.riseStoplossPrice);
							$("#riseAbandonPrice").val(val.riseAbandonPrice);
							$("#fallOpenPrice").val(val.fallOpenPrice);
							$("#fallStoplossPrice").val(val.fallStoplossPrice);
							$("#fallAbandonPrice").val(val.fallAbandonPrice);
							var tmp1 = 0;
							$(val.moreTradeStrategys).each(function(i,obj){
							   if(i<=1){
								   $("#more-remedyPrice"+i).val(obj.triggerPrice);
								   $("#more-sellPrice"+i).val(obj.sellPrice);
							   }else{
								   var clone_obj = $("#more1").clone();
									clone_obj.find("label").html('<span style="color: red">*</span>阶段'+i+'（%）')
									clone_obj.find("input").eq(0).attr("name","moreTradeStrategys["+i+"].triggerPrice");
									clone_obj.find("input").eq(0).attr("id", "more-remedyPrice"+i);
									clone_obj.find("input").eq(1).attr("name","moreTradeStrategys["+i+"].sellPrice");
									clone_obj.find("input").eq(1).attr("id", "more-sellPrice"+i);
									clone_obj.find("input").eq(2).attr("name","moreTradeStrategys["+i+"].tradeStrategyTrendType");
									clone_obj.find("input").eq(2).after('<div class="layui-input-inline">'
																		+'<a href="javascript:;" class="layui-btn layui-btn-danger layui-btn-small" onclick="del(this)" >'
																		+'<i class="layui-icon"></i> 删除'
																		+'</a>'
																		+'</div>');
									$(clone_obj).insertBefore("#more-loop");
									$("#more-remedyPrice"+i).val(obj.triggerPrice);
									$("#more-sellPrice"+i).val(obj.sellPrice);
							   }
							   tmp1++
							 });
							more_index = tmp1-1;
							var tmp2 = 0;
							$(val.nullTradeStrategys).each(function(i,obj){
							   if(i<=1){
								   $("#null-remedyPrice"+i).val(obj.triggerPrice);
								   $("#null-sellPrice"+i).val(obj.sellPrice);
							   }else{
								   var clone_obj = $("#null1").clone();
									clone_obj.find("label").html('<span style="color: red">*</span>阶段'+i+'（%）')
									clone_obj.find("input").eq(0).attr("name","nullTradeStrategys["+i+"].triggerPrice");
									clone_obj.find("input").eq(0).attr("id", "null-remedyPrice"+i);
									clone_obj.find("input").eq(1).attr("name","nullTradeStrategys["+i+"].sellPrice");
									clone_obj.find("input").eq(1).attr("id", "null-sellPrice"+i);
									clone_obj.find("input").eq(2).attr("name","nullTradeStrategys["+i+"].tradeStrategyTrendType");
									clone_obj.find("input").eq(2).after('<div class="layui-input-inline">'
																		+'<a href="javascript:;" class="layui-btn layui-btn-danger layui-btn-small" onclick="del(this)" >'
																		+'<i class="layui-icon"></i> 删除'
																		+'</a>'
																		+'</div>');
									$(clone_obj).insertBefore("#null-loop");
									$("#null-remedyPrice"+i).val(obj.triggerPrice);
									$("#null-sellPrice"+i).val(obj.sellPrice);
							   }
							   tmp2++
							 });
							null_index = tmp2-1;
					
						}	
					}, {
						ProdId : $("#prodId").val()
					});
				}
				
				//获取币种
				ComUtil.AjaxData("#coinId", path + "/a/setting/ConfigAction/queryConfigInfoByType.do", 
					function(obj, data) {
						$("#coinId").empty();
						var data = data.data;
						var html = '<option value="">请选择</option>';
						for (var i = 0; i < data.length; i++) {
							var configObj = data[i]
							if(configObj.configCode==coinId){
								html += '<option value="' + configObj.configCode + '" selected="selected">' + configObj.configName
								+ '</option>'
							}else{
								html += '<option value="' + configObj.configCode + '">' + configObj.configName
								+ '</option>'
							}
							
						}
						$("#coinId").append(html);
						loadPurLevel(coinId,1);
						form.render("select");
				},{configType:"icon"})
				//获取币种对应档位
				function loadPurLevel(coinId,type){
				ComUtil.AjaxData("#purLevel", path + "/a/setting/ConfigAction/queryConfigInfoByType.do", 
					function(obj, data) {
						$("#purLevel").empty();
						var data = data.data;
						var html = '<option value="">请选择</option>';
						for (var i = 0; i < data.length; i++) {
							var configObj = data[i]
							if(configObj.configName==purLevel && type==1){
								html += '<option value="' + configObj.configName + '" selected="selected">' + configObj.configTypeName
								+ '</option>'
							}else{
								html += '<option value="' + configObj.configName + '">' + configObj.configTypeName
								+ '</option>'
							}
							
						}
						$("#purLevel").append(html);
						form.render("select");
				},{configType:"level",configCode:coinId})
				}
				form.on('select(coinIdF)', function(data){
					loadPurLevel(data.elem.value,2);
				});
				$("#more-add").on( 'click',  function (e) {
						if($("#isMoreStrategynew").val()==1) {
								more_index++
								var clone_obj = $("#more1").clone();
								clone_obj.find("label").html('<span style="color: red">*</span>阶段'+more_index+'（%）')
								clone_obj.find("input").eq(0).attr("name","moreTradeStrategys["+more_index+"].triggerPrice");
								clone_obj.find("input").eq(0).attr("id", "more-remedyPrice"+more_index);
								clone_obj.find("input").eq(1).attr("name","moreTradeStrategys["+more_index+"].sellPrice");
								clone_obj.find("input").eq(1).attr("id", "more-sellPrice"+more_index);
								clone_obj.find("input").eq(2).attr("name","moreTradeStrategys["+more_index+"].tradeStrategyTrendType");
								clone_obj.find("input").eq(2).after('<div class="layui-input-inline">'
																	+'<a href="javascript:;" class="layui-btn layui-btn-danger layui-btn-small" onclick="del(this)" >'
																	+'<i class="layui-icon"></i> 删除'
																	+'</a>'
																	+'</div>');
								
								$(clone_obj).insertBefore("#more-loop");
								if($("#isMoreStrategy").val()){
									$("#more-remedyPrice"+more_index).rules("add", {required:true});
									$("#more-sellPrice"+more_index).rules("add", {required:true});
								}

						}  else {
							if($("#isMoreStrategynew").val()==2) {
								more_index++
								var clone_obj = $("#more1").clone();
								clone_obj.find("label").html('<span style="color: red">*</span>阶段'+more_index+'（%）')
								clone_obj.find("input").eq(0).attr("name","moreTradeStrategys["+more_index+"].triggerPrice");
								clone_obj.find("input").eq(0).attr("id", "more-remedyPrice"+more_index);
								clone_obj.find("input").eq(1).attr("name","moreTradeStrategys["+more_index+"].sellPrice");
								clone_obj.find("input").eq(1).attr("id", "more-sellPrice"+more_index);
								clone_obj.find("input").eq(2).attr("name","moreTradeStrategys["+more_index+"].tradeStrategyTrendType");
								clone_obj.find("input").eq(2).after('<div class="layui-input-inline">'
																	+'<a href="javascript:;" class="layui-btn layui-btn-danger layui-btn-small" onclick="del(this)" >'
																	+'<i class="layui-icon"></i> 删除'
																	+'</a>'
																	+'</div>');
								
								$(clone_obj).insertBefore("#more-loop");
								if($("#isMoreStrategy").val()){
									$("#more-remedyPrice"+more_index).rules("add", {required:true});
									$("#more-sellPrice"+more_index).rules("add", {required:true});
								}
							} else {

							}
						}
				})
				
				$("#null-add").on( 'click',  function (e) {
						if($("#isNullStrategynew").val()==1) {
							null_index++
							var clone_obj = $("#null1").clone();
							clone_obj.find("label").html('<span style="color: red">*</span>阶段'+null_index+'（%）');
							clone_obj.find("input").eq(0).attr("name","nullTradeStrategys["+null_index+"].triggerPrice");
							clone_obj.find("input").eq(0).attr("id", "null-remedyPrice"+null_index);
							clone_obj.find("input").eq(1).attr("name","nullTradeStrategys["+null_index+"].sellPrice");
							clone_obj.find("input").eq(1).attr("id", "null-sellPrice"+null_index);
							clone_obj.find("input").eq(2).attr("name","nullTradeStrategys["+null_index+"].tradeStrategyTrendType");
							clone_obj.find("input").eq(2).after('<div class="layui-input-inline">'
									+'<a href="javascript:;" class="layui-btn layui-btn-danger layui-btn-small" onclick="del(this)" >'
									+'<i class="layui-icon"></i> 删除'
									+'</a>'
									+'</div>')
							$(clone_obj).insertBefore("#null-loop")
							if($("#isNullStrategy").val()){
								$("#null-remedyPrice"+null_index).rules("add", {required:true});
								$("#null-sellPrice"+null_index).rules("add", {required:true});
							}
	
					}  else {
						if($("#isNullStrategynew").val()==2) {
							null_index++
							var clone_obj = $("#null1").clone();
							clone_obj.find("label").html('<span style="color: red">*</span>阶段'+null_index+'（%）');
							clone_obj.find("input").eq(0).attr("name","nullTradeStrategys["+null_index+"].triggerPrice");
							clone_obj.find("input").eq(0).attr("id", "null-remedyPrice"+null_index);
							clone_obj.find("input").eq(1).attr("name","nullTradeStrategys["+null_index+"].sellPrice");
							clone_obj.find("input").eq(1).attr("id", "null-sellPrice"+null_index);
							clone_obj.find("input").eq(2).attr("name","nullTradeStrategys["+null_index+"].tradeStrategyTrendType");
							clone_obj.find("input").eq(2).after('<div class="layui-input-inline">'
									+'<a href="javascript:;" class="layui-btn layui-btn-danger layui-btn-small" onclick="del(this)" >'
									+'<i class="layui-icon"></i> 删除'
									+'</a>'
									+'</div>')
							$(clone_obj).insertBefore("#null-loop")
							if($("#isNullStrategy").val()){
								$("#null-remedyPrice"+null_index).rules("add", {required:true});
								$("#null-sellPrice"+null_index).rules("add", {required:true});
							}
						} else {
	
						}
					}
					
				})
				var remedy_index = 1;
				
				FromEngine.vsFrom(".layui-form", {
					debug : false,
					beforeSubmitFunction:function(){
						$("#type").val("<%=type%>");
						return true;
					},
					cfgUrlOrFunction : path + "/a/setting/StrategyAction/saveProductStrategy.do",
					cfgCallBack : function(result) {
						``
					}
				});
				initValidate();
			})
			function initValidate(){
				$("#riseOpenPrice").rules("add", {required:true});
				$("#riseStoplossPrice").rules("add", {required:true});
				$("#riseAbandonPrice").rules("add", {required:true});
				$("#more-remedyPrice1").rules("add", {required:true});
				$("#more-sellPrice1").rules("add", {required:true});
				$("#more-remedyPrice0").rules("add", {required:true}); 
				$("#more-sellPrice0").rules("add", {required:true});
				$("#fallOpenPrice").rules("add", {required:true});
				$("#fallStoplossPrice").rules("add", {required:true});
				$("#fallAbandonPrice").rules("add", {required:true});
				$("#null-remedyPrice1").rules("add", {required:true});
				$("#null-sellPrice1").rules("add", {required:true});
				$("#null-remedyPrice0").rules("add", {required:true}); 
				$("#null-sellPrice0").rules("add", {required:true}); 
			}
			function del(obj){
				$(obj).parent().parent().remove();	
			}
			function accAdd(num1,num2){  
			       var r1,r2,m;  
			       try{  
			           r1 = num1.toString().split('.')[1].length;  
			       }catch(e){  
			           r1 = 0;  
			       }  
			       try{  
			           r2=num2.toString().split(".")[1].length;  
			       }catch(e){  
			           r2=0;  
			       }  
			       m=Math.pow(10,Math.max(r1,r2));  
			       // return (num1*m+num2*m)/m;  
			       return Math.round(num1*m+num2*m)/m;  
			    }  
			      
			    // 两个浮点数相减  
			    function accSub(num1,num2){  
			       var r1,r2,m;  
			       try{  
			           r1 = num1.toString().split('.')[1].length;  
			       }catch(e){  
			           r1 = 0;  
			       }  
			       try{  
			           r2=num2.toString().split(".")[1].length;  
			       }catch(e){  
			           r2=0;  
			       }  
			       m=Math.pow(10,Math.max(r1,r2));  
			       n=(r1>=r2)?r1:r2;  
			       return (Math.round(num1*m-num2*m)/m).toFixed(n);  
			    }  
			    // 两数相除  
			    function accDiv(num1,num2){  
			       var t1,t2,r1,r2;  
			       try{  
			           t1 = num1.toString().split('.')[1].length;  
			       }catch(e){  
			           t1 = 0;  
			       }  
			       try{  
			           t2=num2.toString().split(".")[1].length;  
			       }catch(e){  
			           t2=0;  
			       }  
			       r1=Number(num1.toString().replace(".",""));  
			       r2=Number(num2.toString().replace(".",""));  
			       return (r1/r2)*Math.pow(10,t2-t1);  
			    }  
			      
			    function accMul(num1,num2){  
			       var m=0,s1=num1.toString(),s2=num2.toString();   
			    try{m+=s1.split(".")[1].length}catch(e){};  
			    try{m+=s2.split(".")[1].length}catch(e){};  
			    return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m);  
			    }  
		</script>
	<style type="text/css">
    	.strategyclass .layui-input{ 
	    	color:#F8F8F8;
	    	background-color: #f8f8f8;
	    	border: 0.5px solid #f8f8f8;
    	}
    	.strategyclass { 
	    	color:#F8F8F8;
    	}
    	
	</style>
	</body>	
</html>